<template>
  <div>
    <van-nav-bar left-text="返回" left-arrow @click-left="onClickLeft" fixed />
    <van-pull-refresh v-model="isLoading" success-text="刷新成功" @refresh="onRefresh">
      <div class="yM-sH-Main">
        <div class="yM-lable">
          <div class="content">
            <div class="mask">榜单</div>
          </div>
        </div>
        <h3>{{rListInfo.rankname}}</h3>
        <h4>歌曲列表</h4>
        <ul>
          <li v-for="(item,index) in rListSongs" :key="item.audio_id">
            <span class="yM-sort">{{ index+1 < 10 ? '0'+(index + 1) : index+1 }}</span>
            <span class="yM-title">{{item.filename}}</span>
          </li>
        </ul>
      </div>
    </van-pull-refresh>
  </div>
</template>
<script>
export default {
  data() {
    return {
      rListSongs: [],
      rListInfo: {},
      isLoading: false
    }
  },
  created: function() {
    this.getRlistSongs()
  },
  methods: {
    onClickLeft: function() {
      this.$router.go(-1)
    },
    getRlistSongs: async function() {
      const { data: res } = await this.axios.get(
        'api/rank_list_info/' + this.$route.query.rankid
      )
      if (res.code === 200) {
        this.rListInfo = res.data.info
        this.rListSongs = res.data.songs.list
      }
    },
    onRefresh() {
      setTimeout(() => {
        this.$toast('刷新成功')
        this.isLoading = false
        this.getRlistSongs()
      }, 1000)
    }
  }
}
</script>
<style scoped lang="less">
.yM-sH-Main {
  color: #000;
  padding: 0 60px;
  color: #333;
  .yM-lable {
    margin-top: 200px;
    width: 100%;
    text-align: center;
    .content {
      display: inline-block;
      width: 400px;
      height: 400px;
      background-image: url('../assets/img/yM-fS-item.jpg');
      background-size: contain;
      border-radius: 40px;
      .mask {
        width: 100%;
        height: 100%;
        background-color: #000;
        opacity: 0.7;
        text-align: center;
        line-height: 400px;
        border-radius: 40px;
        color: #fff;
        font-size: 100px;
      }
    }
  }
  h3 {
    text-align: center;
  }
  ul {
    li {
      margin-bottom: 40px;
      .yM-sort {
        padding-right: 50px;
      }
    }
  }
}
</style>